package com.departmentstore.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Set;

@Data
@Entity
@Table(name = "manufacturer")
public class Manufacturer {
    @Id
    @Column(name = "manufacturer_id", length = 10)
    @NotBlank(message = "制造商ID不能为空")
    @Size(min = 1, max = 10, message = "制造商ID长度必须在1-10之间")
    private String manufacturerId;

    @Column(name = "name", length = 50)
    @NotBlank(message = "制造商名称不能为空")
    @Size(min = 1, max = 50, message = "制造商名称长度必须在1-50之间")
    private String name;

    @Column(name = "address", length = 200)
    @NotBlank(message = "地址不能为空")
    private String address;

    @Column(name = "contact_person", length = 50)
    @NotBlank(message = "联系人不能为空")
    private String contactPerson;

    @Column(name = "phone", length = 20)
    @NotBlank(message = "联系电话不能为空")
    private String phone;

    @Column(name = "email", length = 100)
    @NotBlank(message = "电子邮箱不能为空")
    private String email;

    @OneToMany(mappedBy = "manufacturer", fetch = FetchType.LAZY)
    @JsonIgnore
    private Set<ManufacturerProduct> manufacturerProducts;
} 